/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbravo.pos.panels.link.model;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;

import com.openbravo.pos.base.AppLocal;
import com.openbravo.bean.ProductLocationState;
import com.openbravo.bean.viewbean.ProductStoreView;
import com.openbravo.format.Formats;

/**
 *
 * @author Administrator
 */
public class ProductStoreVTableModel extends AbstractDTOTableModel<ProductStoreView>{


        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
           ProductStoreView value=getObj(rowIndex);
           switch(columnIndex){
               case 0:
                   return value.getM_Location();
               case 1:
                   return value.getAttrsetInsDesc();
               case 2:
                   return  value.getM_unit();
               case 3:
                   return value.getM_sName();
               case 4:
            	   return Formats.TIMESTAMP.formatValue(value.getInDate());
               case 5:
            	   return value.getInReason();
               case 6:
            	   return Formats.TIMESTAMP.formatValue(value.getOutDate());
               case 7:
            	   return value.getOutReason();
               case 8:
            	   return getNameByState(value.getState());
           }
           return null;
        }

		@Override
		public String[] getColumnNames() {
			return new String[]{
		            AppLocal.getIntString("label.warehouse"),
		            AppLocal.getIntString("label.attribute"),
		            AppLocal.getIntString("label.storeNum"),
		            AppLocal.getIntString("label.item"),
		            AppLocal.getIntString("label.inDate"),
		            AppLocal.getIntString("label.inReason"),
		            AppLocal.getIntString("label.outDate"),
		            AppLocal.getIntString("label.outReason"),
		            AppLocal.getIntString("label.productLocationState")
		          };
		}

		public static String getNameByState(int state){
			if(state==ProductLocationState.STATE_IN)
				return AppLocal.getIntString("label.productLocationState.in");
			else if(state==ProductLocationState.STATE_OUT)
				return AppLocal.getIntString("label.productLocationState.out");
			else if(state==ProductLocationState.STATE_LOCK)
				return AppLocal.getIntString("label.productLocationState.lock");
			return null;
		}
		
}